<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>主</title>
<import type='css' file="css.main" />
<load href="__PUBLIC__/js/jquery-1.9.1.min.js" />
<import type='js' file="js.main" />
	<style type="text/css">
		body{font-size: 14px;}
		h1.infotitle{display: block; text-align: center; line-height: 36px; clear: both; overflow: hidden; margin-top: 60px; font-weight: normal; font-size: 32px;}
		.info{clear: both; overflow: hidden; text-align: center; margin-top: 30px; font-size: 18px;}
		.info *{display: inline;}
		.info .test{border: solid 1px #ccc; letter-spacing:1px; border-radius: 5px; height: 24px; line-height: 24px; padding: 2px 20px; font-size: 16px; text-align: center; background-color: #fff;}
		.info .submit{background-color: #00A388; border-radius: 3px; color: #fff; font-weight:bold; border: none; padding: 5px 23px; font-size: 16px; cursor: pointer;}
		.tableinfo{width: 80%; margin: 0px auto; clear: both; margin-top: 50px;}
		table{border-collapse:collapse; border: solid 1px #ebebeb; border-color: #ebebeb;}
		table th{height: 40px; line-height: 40px; background-color: #00A388; color: #fff; font-weight: normal; font-size: 16px;}
		table tr td{text-align: center; padding: 5px;}
		a.setstatus{width: 80px; display: block; margin: 0px auto; text-align: center; color: #fff; cursor: pointer; background-color: #ff5454; padding: 4px 5px; border-radius:5px;}
	</style>
</head>

<body>  
<h1 class="infotitle">中奖查询</h1>
<div class="info">
	<form action="{:U('queryaward',array('s'=>1))}" name="form1" id="form1" method="post">
		<label>手机号码：</label>
		<input type="text" name="key" class="test" placeholder="请输入手机号码" value="{$key}" />
		<input type="submit" class="submit" value="查询" />
	</form>
</div>
<assign name="s" value="$Think.get.s" />
<if condition="$s neq ''">
<div class="tableinfo">
	<table width="100%" border="1" cellspacing="0" cellpadding="0" class="indextable">
		<tr>
			<th width="5%">ID</th>
			<th width="15%">姓名</th>
			<th width="15%">手机号</th>
			<th width="25%">奖品名称</th>
			<th width="15%">奖品图片</th>
			<th width="10%">领取状态</th>
			<th width="15%">操作</th>
		</tr>
		<volist name="result" id="v" empty="没有数据">
		<tr>
			<td>{$v['id']}</td>
			<td>{$v['name']}</td>
			<td>{$v['mobile']}</td>
			<td>{:W('Jgward/getaward',array('id'=>$v['awardid'],'field'=>'awardname'))}</td>
			<td><img src="{:W('Jgward/getaward',array('id'=>$v['awardid'],'field'=>'awardimg'))}" height="50" /></td>
			<td class="astatus">{:W('Jgward/awardstatus',array('id'=>$v['id']))}</td>
			<td>{:W('Jgward/awardstatus',array('id'=>$v['id'],'f'=>1))}</td>
		</tr>
		</volist>
	</table>
</div>
</if>
<script type="text/javascript">
	$(function(){
		$(".setstatus").each(function(index,element){
			var t = $(this);
			t.click(function(){
				var id = $(this).attr('v');
				if(id!=''){
					var savetel_url = "{:U('changestatus')}";
					var teldata = {"id":id,random:Math.random()};
					$.ajax({
						url:savetel_url,
						data:teldata,
						type:"POST",
						dataType:"JSON",
						success:function (data){
							if(data.ret==1){
								$(".setstatus").remove();
								$(".astatus:eq("+index+")").html("已领取");
							}else{
								alert('设置失败，请重新查询再次设置');
							}
						}
					});
				}
			})
		})
	})
</script>
</body>
</html>
